// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module.exports = {
	_before: function() { // 通用预处理器

	},

	/**
	 * 获取课程章节列表
	 */
	async getList(courseId, skip = 0, limit = 8) {
		const dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		return await dbJQL.collection("course-chapter").where(`courseId=='${courseId}'`)
			.skip(skip).limit(limit).orderBy("createTime asc")
			.get();
	},
	async attachment_list(courseId, pageNo, pageSize) {
		const dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		let offset = (pageNo - 1) * pageSize
		return await dbJQL.collection('course-attachment').where(`courseId=='${courseId}'`)
			.skip(offset).limit(pageSize)
			.get()
	}
}